const {
  DataTypes
} = require('sequelize');
module.exports = sequelize => {
  const attributes = {
    id: {
      type: DataTypes.BIGINT.UNSIGNED,
      allowNull: false,
      defaultValue: null,
      primaryKey: true,
      autoIncrement: true,
      comment: "退款日志id",
      field: "id"
    },
    pay_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付id",
      field: "pay_id"
    },
    user_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "用户id",
      field: "user_id"
    },
    business_id: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "业务订单id",
      field: "business_id"
    },
    business_type: {
      type: DataTypes.CHAR(180),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "业务类型，字符串（如：订单、钱包充值、会员购买、等...）",
      field: "business_type"
    },
    trade_no: {
      type: DataTypes.CHAR(100),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付平台交易号",
      field: "trade_no"
    },
    buyer_user: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付平台用户帐号",
      field: "buyer_user"
    },
    refund_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "退款金额",
      field: "refund_price"
    },
    pay_price: {
      type: DataTypes.DECIMAL,
      allowNull: false,
      defaultValue: "0.00",
      primaryKey: false,
      autoIncrement: false,
      comment: "订单实际支付金额",
      field: "pay_price"
    },
    msg: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "描述",
      field: "msg"
    },
    payment: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付方式标记",
      field: "payment"
    },
    payment_name: {
      type: DataTypes.CHAR(60),
      allowNull: false,
      defaultValue: "",
      primaryKey: false,
      autoIncrement: false,
      comment: "支付方式名称",
      field: "payment_name"
    },
    refundment: {
      type: DataTypes.INTEGER(3).UNSIGNED,
      allowNull: false,
      defaultValue: "0",
      primaryKey: false,
      autoIncrement: false,
      comment: "退款类型（0原路退回, 1退至钱包, 2手动处理）",
      field: "refundment"
    },
    return_params: {
      type: DataTypes.TEXT,
      allowNull: true,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "支付平台返回参数（以json存储）",
      field: "return_params"
    },
    add_time: {
      type: DataTypes.INTEGER(10).UNSIGNED,
      allowNull: false,
      defaultValue: null,
      primaryKey: false,
      autoIncrement: false,
      comment: "添加时间",
      field: "add_time"
    }
  };
  const options = {
    tableName: "sxo_refund_log",
    comment: "",
    indexes: [{
      name: "payment",
      unique: false,
      type: "BTREE",
      fields: ["payment"]
    }, {
      name: "business_id",
      unique: false,
      type: "BTREE",
      fields: ["business_id"]
    }, {
      name: "business_type",
      unique: false,
      type: "BTREE",
      fields: ["business_type"]
    }, {
      name: "pay_id",
      unique: false,
      type: "BTREE",
      fields: ["pay_id"]
    }]
  };
  const SxoRefundLogModel = sequelize.define("sxo_refund_log_model", attributes, options);
  return SxoRefundLogModel;
};